/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;

/**
 *
 * @author Evistix
 */
public class Index extends javax.swing.JFrame {

    /**
     * Creates new form Index
     */
    public static int login;
    public Index() {
        initComponents();
        this.setSize(840, 580);
        this.setLocation(500, 250);
        this.setIconImage(java.awt.Toolkit.getDefaultToolkit().createImage((getClass().getResource("/icon/nailuo.jpg"))));
        this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        int login=0;
        String 用户名="";
        String 密码="";
        头像.setVisible(false);
        欢迎.setVisible(false);
        退出登录.setVisible(false);
        vip.setVisible(false);
        vipB.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        语言 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        bg = new javax.swing.JPanel();
        头像 = new javax.swing.JLabel();
        退出登录 = new javax.swing.JButton();
        欢迎 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        防护中心 = new javax.swing.JLabel();
        病毒查杀 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        vipB = new javax.swing.JButton();
        vip = new javax.swing.JLabel();
        bgl = new javax.swing.JLabel();
        菜单 = new javax.swing.JMenuBar();
        下拉菜单 = new javax.swing.JMenu();
        登录 = new javax.swing.JMenuItem();
        设置 = new javax.swing.JMenuItem();
        语言切换 = new javax.swing.JMenu();
        中文 = new javax.swing.JRadioButtonMenuItem();
        英文 = new javax.swing.JRadioButtonMenuItem();
        问题反馈 = new javax.swing.JMenuItem();
        关于 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();

        jLabel1.setText("jLabel1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("绿山毒霸");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        bg.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        头像.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/头像.png"))); // NOI18N
        bg.add(头像, new org.netbeans.lib.awtextra.AbsoluteConstraints(630, 70, 110, 90));

        退出登录.setText("退出登录");
        退出登录.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                退出登录ActionPerformed(evt);
            }
        });
        bg.add(退出登录, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 250, -1, -1));

        欢迎.setFont(new java.awt.Font("宋体", 1, 14)); // NOI18N
        欢迎.setText("尊敬的 xxx 欢迎使用");
        bg.add(欢迎, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 180, -1, -1));

        jLabel2.setText("版本号:v1.0.2");
        bg.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(730, 510, 90, 30));

        防护中心.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                防护中心MouseClicked(evt);
            }
        });
        bg.add(防护中心, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 360, 130, 140));

        病毒查杀.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                病毒查杀MouseClicked(evt);
            }
        });
        bg.add(病毒查杀, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 360, 130, 140));

        jLabel3.setFont(new java.awt.Font("微软雅黑", 1, 36)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(51, 0, 255));
        jLabel3.setText("绿山毒霸");
        bg.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 80, 150, 50));

        vipB.setText("VIP激活");
        vipB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vipBActionPerformed(evt);
            }
        });
        bg.add(vipB, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 210, 80, -1));

        vip.setFont(new java.awt.Font("宋体", 1, 24)); // NOI18N
        vip.setForeground(new java.awt.Color(102, 102, 255));
        vip.setText("VIP");
        bg.add(vip, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 210, 80, 30));

        bgl.setIcon(new javax.swing.ImageIcon(getClass().getResource("/background/index.png"))); // NOI18N
        bgl.setOpaque(true);
        bg.add(bgl, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        下拉菜单.setText("▼");

        登录.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        登录.setText("登录/注册");
        登录.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                登录ActionPerformed(evt);
            }
        });
        下拉菜单.add(登录);

        设置.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK));
        设置.setText("安全设置");
        设置.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                设置ActionPerformed(evt);
            }
        });
        下拉菜单.add(设置);

        语言切换.setText("语言切换");

        语言.add(中文);
        中文.setSelected(true);
        中文.setText("中文");
        中文.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                中文ActionPerformed(evt);
            }
        });
        语言切换.add(中文);

        语言.add(英文);
        英文.setText("英文");
        英文.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                英文ActionPerformed(evt);
            }
        });
        语言切换.add(英文);

        下拉菜单.add(语言切换);

        问题反馈.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        问题反馈.setText("问题反馈");
        问题反馈.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                问题反馈ActionPerformed(evt);
            }
        });
        下拉菜单.add(问题反馈);

        关于.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK));
        关于.setText("关于");
        关于.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                关于ActionPerformed(evt);
            }
        });
        下拉菜单.add(关于);

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("帮助");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        下拉菜单.add(jMenuItem1);

        菜单.add(下拉菜单);

        setJMenuBar(菜单);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(bg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(bg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        if( JOptionPane.showConfirmDialog( null, "确定关闭窗口吗？", "确认", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE ) == JOptionPane.YES_OPTION ){
            System.exit(0);
        }
        else{
           
        }
    }//GEN-LAST:event_formWindowClosing

    private void 登录ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_登录ActionPerformed
        // TODO add your handling code here:
        if(login==0) new Login(this,true).setVisible( true );
        else {
             javax.swing.JOptionPane.showMessageDialog(rootPane,"已登录"); 
        }
    }//GEN-LAST:event_登录ActionPerformed

    private void 设置ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_设置ActionPerformed
        // TODO add your handling code here:
        new Set(this,true).setVisible( true );
    }//GEN-LAST:event_设置ActionPerformed

    private void 英文ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_英文ActionPerformed
        // TODO add your handling code here:
        javax.swing.JOptionPane.showMessageDialog(rootPane,"已切换成英文");
    }//GEN-LAST:event_英文ActionPerformed

    private void 退出登录ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_退出登录ActionPerformed
        // TODO add your handling code here:
         
        login=0;
        头像.setVisible(false);
        欢迎.setVisible(false);
        退出登录.setVisible(false);
        vipB.setVisible(false);
        vip.setVisible(false);javax.swing.JOptionPane.showMessageDialog(rootPane,"已成功退出登录");
    }//GEN-LAST:event_退出登录ActionPerformed

    private void 中文ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_中文ActionPerformed
        // TODO add your handling code here:
        javax.swing.JOptionPane.showMessageDialog(rootPane,"已切换成中文"); 
    }//GEN-LAST:event_中文ActionPerformed

    private void 问题反馈ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_问题反馈ActionPerformed
        // TODO add your handling code here:
        new Feedback(this,true).setVisible( true );
    }//GEN-LAST:event_问题反馈ActionPerformed

    private void 关于ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_关于ActionPerformed
        // TODO add your handling code here:
         new About(this,true).setVisible( true );
    }//GEN-LAST:event_关于ActionPerformed

    private void 病毒查杀MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_病毒查杀MouseClicked
        // TODO add your handling code here:
       
        //this.setVisible(false);
        new SD(this,false).setVisible( true );
    }//GEN-LAST:event_病毒查杀MouseClicked

    private void 防护中心MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_防护中心MouseClicked
        // TODO add your handling code here:
         new Protect(this,false).setVisible( true );
    }//GEN-LAST:event_防护中心MouseClicked

    private void vipBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vipBActionPerformed
        // TODO add your handling code here:
        new VIP(this,false).setVisible( true );
    }//GEN-LAST:event_vipBActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        System.out.println(this.getClass().getResource("/help/bz.chm").toString().substring(5));
        File f=new File(this.getClass().getResource("/help/bz.chm").toString().substring(5));
      //  File f=new File("d:\\bz.chm");
        System.out.println(f.exists());
        System.out.println(f.isDirectory());
        try {
           // Runtime.getRuntime().exec("explorer /e,/select,"+f.getAbsolutePath());
            Desktop.getDesktop().open(f);
        }catch(Exception e){
            
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Index.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Index.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Index.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Index.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Index().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel bg;
    private javax.swing.JLabel bgl;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenuItem jMenuItem1;
    public static javax.swing.JLabel vip;
    public static javax.swing.JButton vipB;
    private javax.swing.JMenu 下拉菜单;
    private javax.swing.JRadioButtonMenuItem 中文;
    private javax.swing.JMenuItem 关于;
    public static javax.swing.JLabel 头像;
    public static javax.swing.JLabel 欢迎;
    private javax.swing.JLabel 病毒查杀;
    private javax.swing.JMenuItem 登录;
    private javax.swing.JRadioButtonMenuItem 英文;
    private javax.swing.JMenuBar 菜单;
    private javax.swing.JMenuItem 设置;
    private javax.swing.ButtonGroup 语言;
    private javax.swing.JMenu 语言切换;
    public static javax.swing.JButton 退出登录;
    private javax.swing.JMenuItem 问题反馈;
    private javax.swing.JLabel 防护中心;
    // End of variables declaration//GEN-END:variables
}
